package  
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import vk.APIConnection;
	/**
	 * ...
	 * @author 
	 */
	
	public class Gamer extends EventDispatcher
	{
		static public const STORES_RECEIVED = "storesReceived";
		private var vKontakte: APIConnection = null;
		
		public function Gamer(apiConnection:APIConnection, user_id: Number, name: String , surname: String, photo: String, scores: Number = 0) 
		{
			this.scores = scores;
			this.name = name;
			this.surname = surname;
			this.photo = photo;
			this.user_id = user_id;
			this.vKontakte = apiConnection;
		}
		
		function receiveScores(vkAnswer: Object): void {
			scores = Number(vkAnswer);
			dispatchEvent(new Event(STORES_RECEIVED));
			trace("receiveScores()", this.name, " ", this.surname, " ", scores);
			
		}
		
		private function tryAgain(o: Object) {
			trace("tryAgain()");
			startReceiveScores();
		}
		function startReceiveScores() {
			/*main.vKontakte.api ("getVariable", { key: Scores.USER_SCORES, user_id: friends[scoresQueried].user_id}, 
				friends[scoresQueried].receiveScores, vkFail);*/
			trace("startReceiveScores");
			vKontakte.api ("getVariable", { key: Scores.USER_SCORES, user_id: user_id}, 
				receiveScores, tryAgain);
		}
			
			
		var user_id: Number = 0;
		public var scores: Number = 0;
		var name: String = null;
		var surname: String = null;
		var photo: String = null;	//Link to a photo
	}

}